package com.changdu.seatunnel.admin.config.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

import lombok.Getter;

@Getter
public enum SyncTaskType {
	
    FULL(0, "全量", "initial", "latest"),
    INCREMENT(1, "增量", "latest", "never"),
    FULL_AND_INCREMENT(2, "全量/增量", "initial", "never"),
	;
	
    @EnumValue
    private final int code;
    private final String description;
    private final String startmode;
    private final String stopmode;

    SyncTaskType(int code, String description, String startmode, String stopmode) {
        this.code = code;
        this.description = description;
        this.startmode = startmode;
        this.stopmode = stopmode;
    }

	public static SyncTaskType fromCode(int code) {
		for (SyncTaskType status : SyncTaskType.values()) {
			if (status.code == code) {
				return status;
			}
		}
		throw new IllegalArgumentException("Unknown code: " + code);
	}
	
	public static SyncTaskType fromSyncMode(String startmode, String stopmode) {
		for (SyncTaskType status : SyncTaskType.values()) {
			if (status.startmode.equalsIgnoreCase(startmode) && status.stopmode.equalsIgnoreCase(stopmode)) {
				return status;
			}
		}
		throw new IllegalArgumentException("Unknown startmode: " + startmode + ", stopmode: " + stopmode);
	}
	
}